package com.weicx.wuzhiops.controller;

import com.weicx.wuzhiops.annotation.EventLog;
import com.weicx.wuzhiops.annotation.RestWrapper;
import com.weicx.wuzhiops.constant.event.EventType;
import com.weicx.wuzhiops.model.request.UserInfoRequest;
import com.weicx.wuzhiops.service.UserInfoService;
import com.weicx.wuzhiops.util.ServletsUtil;
import com.weicx.wuzhiops.util.Valid;
import com.weicx.wuzhiops.vo.UserInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author:
 * @date: 2022-12-08 09:43:27
 * @since: 1.0
 */
@Api(value = "用户信息", tags = {"用户信息"})
@RestController
@RestWrapper
@RequestMapping(ServletsUtil.BASE_REQUEST_PATH_PREFIX + "/user/info")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @PostMapping("/getByUserId")
    @ApiOperation(value = "根据用户ID获取用户信息")
    public UserInfoVO getByUserId(@RequestBody UserInfoRequest request) {
        Valid.notNull(request.getId());
        return userInfoService.getById(request.getId());
    }


    @PostMapping("/update")
    @ApiOperation(value = "更新用户信息")
    @EventLog(value = EventType.UPDATE_USER)
    public Integer update(@RequestBody UserInfoRequest request) {
        Valid.notNull(request.getId());
        return userInfoService.updateUser(request);
    }




}
